package com.pmenergy.control;
// Generated 19/09/2014 07:43:21 PM by Hibernate Tools 3.4.0.CR1

import java.math.BigDecimal;
import java.util.List;

import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.pmenergy.model.Item;
import com.pmenergy.model.ManoObra;

/**
 * Home object for domain model class ManoObra.
 * @see .ManoObra
 * @author Hibernate Tools
 */
@Stateless
public class ManoObraHome {

	private static final Log log = LogFactory.getLog(ManoObraHome.class);

	@PersistenceContext
	private EntityManager entityManager;

	public void persist(ManoObra transientInstance) {
		log.debug("persisting ManoObra instance");
		try {
			entityManager.persist(transientInstance);
			log.debug("persist successful");
		} catch (RuntimeException re) {
			log.error("persist failed", re);
			throw re;
		}
	}

	public void remove(ManoObra persistentInstance) {
		log.debug("removing ManoObra instance");
		try {
			entityManager.remove(persistentInstance);
			log.debug("remove successful");
		} catch (RuntimeException re) {
			log.error("remove failed", re);
			throw re;
		}
	}

	public ManoObra merge(ManoObra detachedInstance) {
		log.debug("merging ManoObra instance");
		try {
			ManoObra result = entityManager.merge(detachedInstance);
			log.debug("merge successful");
			return result;
		} catch (RuntimeException re) {
			log.error("merge failed", re);
			throw re;
		}
	}
	
	public List<ManoObra> findAllManosObra() {
		log.debug("getting all ManosObra instances " );
		try {
			List<ManoObra> list = entityManager.createQuery("SELECT c FROM ManoObra c ").getResultList();
			log.debug("get successful");
			return list;
		} 
		catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
	
	public ManoObra findById(BigDecimal id) {
		log.debug("getting ManoObra instance with id: " + id);
		try {
			ManoObra instance = entityManager.find(ManoObra.class, id);
			log.debug("get successful");
			return instance;
		} catch (RuntimeException re) {
			log.error("get failed", re);
			throw re;
		}
	}
}
